package com.category.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.category.app.dao.CategoryMapper;
import com.category.app.service.CategoryService;
import com.tamll.bean.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;


    @Override
    public Page<Category> getList(Integer pageNumber,Integer num) {
        Page<Category> categoryPage = new Page<>(pageNumber,num);
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        Page<Category> page = categoryMapper.selectPage(categoryPage, queryWrapper);
        System.out.println("总页数:"+categoryPage.getPages());
        System.out.println("总记录数:"+categoryPage.getTotal());
        return page;
    }

    @Override
    public Category SelectCategory(Integer categoryId) {
        QueryWrapper<Category> queryWrapper = new QueryWrapper();
        queryWrapper.eq("category_id",categoryId);
        Category category = categoryMapper.selectOne(queryWrapper);
        return category;
    }
}
